﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="./css/base.css">
    <link rel="stylesheet" type="text/css" href="./css/login.css">
</head>

<body>
    <div class="container">
        <div class="main clearfix">
            <div class=" part-l">
                <a href="" class="logo-area">
                    <img src="">
                    <p>企业版</p>
                </a>
            </div>
            <div class=" part-r">
                <div class="login-area">
                    <div class="account-area" id="accountArea">
                        <h4 class="title">账号登录</h4>
                        <div class="group">
                            <label class="label user"></label>
                            <input type="text" class="input" id="account" placeholder="用户名">
                        </div>
                        <div class="group">
                            <label class="label lock"></label>
                            <input type="password" class="input" id="password" placeholder="密码">
                        </div>
                        <p class="more-tip">
                            <label for="auto" class="fl">
                                <input type="checkbox" class="checkbox" id="auto" name="auto"> 自动登录
                            </label>
                            <a href="" class="fr forget">忘记密码？</a>
                        </p>
                        <a href="javascript:;" class="btn" id="loginBtn">登 录</a>
                    </div>
                    <div class="wx-area" id="wxArea">
                        <h4 class="title">扫码安全登录</h4>
                        <img src="./images/login/qrcode.jpg" class="qrcode" alt="">
                        <a href="javascript:;" class="refresh">刷新二维码</a>
                    </div>
                    <a href="javascript:;" class="wx-icon" id="wxIcon"></a>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="js.cookie.js"></script>
    <script type="text/javascript">
    $(function() {
        var $wxIcon = $("#wxIcon"),
            $wxArea = $("#wxArea"),
            $accountArea = $("#accountArea"),
            $loginBtn = $("#loginBtn"),
            $account = $("#account"),
            $password = $("#password");

        //微信扫码，帐号登录互换
        var flag = true;
        $wxIcon.click(function() {
            if (flag) {
                $wxArea.show().animate({
                    width: '100%',
                    height: '100%'
                }, 500, function() {
                    flag = false;
                });
            } else {
                $wxArea.animate({
                    width: '0',
                    height: '0'
                }, 500, function() {
                    flag = true;
                    $wxArea.hide();
                });
            }
        });

        //帐号登录
        $loginBtn.click(function() {
            formSubmit();
        });

        //回车登录
        $(document).keydown(function(e){
        	if(e.keyCode  == 13){
        		formSubmit();
        	}
        });

        function formSubmit() {
            if (emptyCheck($account) & emptyCheck($password)) {
                $.ajax({
                    url: 'http://121.40.112.41:881/api/Account/Login/',
                    //url: 'http://localhost:56981/api/Account/Login/',
                    type: 'post',
                    data: {
                        account: $.trim($account.val()),
                        password: $.trim($password.val())
                    },
                    dataType: 'json'
                }).done(function(redata) {
                    if(redata.recode == '0000'){
                    	window.location.href = '/#Standard_List';
						$.cookie('token', redata.token);
						$.cookie('account', $.trim($account.val()));
                    }else{
                    	alert(redata.resmessage);
                    }
                });
            }
        }

        $account.blur(function() {
            emptyCheck($account);
        });

        $password.blur(function() {
            emptyCheck($password);
        });

        function emptyCheck($obj) {
            if ($obj.val() == '') {
                $obj.parents('.group').addClass('error');
                return false;
            } else {
                $obj.parents('.group').removeClass('error');
                return true;
            }
        }
    });
    </script>
</body>

</html>
